package com.dianganjiao.lib.work

import android.content.Context
import android.content.Intent
import android.view.View
import com.dianganjiao.lib.base.AbsActivity

abstract class AbsViewWork : AbsWork() {

    open lateinit var rootView:View

    override fun onWorkCreate(vararg args: Any) {
        rootView = args[0] as View
        onCreateWork(*args)
    }

    abstract fun onCreateWork(vararg args: Any)

    fun getContext() : Context {
        return rootView.context
    }

    fun startActivity(clazz:Class<*>){
        getContext().startActivity(Intent(getContext(),clazz))
    }

    fun getActivity(): AbsActivity {
        return getContext() as AbsActivity
    }

    fun finish(){
        getActivity().finish()
    }
}